﻿using Microsoft.Extensions.Configuration;

namespace XLAction.GlobalIPReqAction
{
    public class GetConfigToJson
    {
        public static string GetConfiguration(string configKey,string jsonaddress)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile(jsonaddress);
            var config = builder.Build();
            if (configKey.Contains(":"))
            {
                return config.GetSection(configKey).Value;//获取分级参数值
            }
            else
            {
                return config[configKey];//获取直级参数值
            }

        }
    }
}
